<%= page_title "Vault servers" %>

<section class="clearfix">
  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Address</th>
        <th>SSL</th>
        <th>Cert</th>
        <th>Used by</th>
        <th></th>
      </tr>
    </thead>

    <tbody>
      <% deploy_groups = DeployGroup.where.not(vault_server_id: nil) %>
      <% @vault_servers.each do |vault_server| %>
        <tr>
          <td><%= vault_server.name %></td>
          <td><%= vault_server.address %></td>
          <td><%= vault_server.tls_verify ? "YES" : "NO" %></td>
          <td><%= vault_server.ca_cert.present? ? "YES" : "NO" %></td>
          <td>
            <% deploy_groups.select { |dg| dg.vault_server_id == vault_server.id }.each do |deploy_group| %>
              <%= link_to deploy_group.name, deploy_group %><br/>
            <% end %>
          </td>
          <td>
            <%= link_to "Edit", vault_server %> |
            <%= link_to_delete vault_server %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>

  <div class="admin-actions">
    <div class="pull-right">
      <%= link_to "New", new_vault_server_path, class: "btn btn-default" %>
    </div>
  </div>
</section>
